<include file="Public:header" />


<script>
$(function(){
    $('#user_pwd').focus();   //将焦点定位在原始密码框中user_pwd
    $('#tijiao').click(
        function(){
            var user_pwd=$('#user_pwd').val();
            var n_user_pwd=$('#n_user_pwd').val();
            var t_user_pwd=$('#t_user_pwd').val();
            if(check(user_pwd,n_user_pwd,t_user_pwd))
                {
                    $.post("{:U('user/save_change_pwd')}",
                    {'user_pwd':user_pwd,
                        'n_user_pwd':n_user_pwd,
                        't_user_pwd':t_user_pwd
                    },
                    function(data){chuli(data.status);},'json')
                }
        });

        function chuli(status){
        switch(status)
        {
            case 0:   //原始密码不正确
                $('#pop').html('<font color="red">原始密码不正确！请核对后重新输入！</font>');
                $('#new_pop').html('<img src="__ROOT__/images/error.gif">');
                $('#user_pwd').val('');
                $('#user_pwd').focus();
                break;
            case 1:   //密码修改成功
                $('#pop').html('<font color="red">密码修改成功！请牢记您的新密码！</font>');
                $('#user_pwd').val('');
                $('#n_user_pwd').val('');
                $('#t_user_pwd').val('');
                break;
            case 2:   //新密码不一致
                $('#pop').html('<font color="red">两次输入的新密码不一致，请确认后重新输入！</font>');
                $('#n_user_pwd').val('');
                $('#t_user_pwd').val('');
                $('#new_n_pop').html('<img src="__ROOT__/images/error.gif">');
                $('#new_t_pop').html('<img src="__ROOT__/images/error.gif">');
                $('#n_user_pwd').focus();
                break;
            case 3:  //系统错误
                $('#pop').html('<font color="red">系统发生错误！请刷新网页后重新更改密码！</font>');
                $('#user_pwd').val('');
                $('#n_user_pwd').val('');
                $('#t_user_pwd').val('');
                $('#user_pwd').focus();
                break;
        }
    }

    function check(user_pwd,n_user_pwd,t_user_pwd)
    {
        if(user_pwd=='')
            {
               $('#pop').html('<font color="red">原始密码不能为空！请正确填写原始密码！</font>');
               $('#new_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#user_pwd').focus();
               return false;
            }
        if(n_user_pwd=='')
            {
                $('#pop').html('<font color="red">新密码不能为空！请填写新密码！</font>');
                $('#new_n_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#n_user_pwd').focus();
               return false;
            }
        if(t_user_pwd=='')
            {
                $('#pop').html('<font color="red">确认新密码不能为空！请填写确认密码！</font>');
               $('#new_t_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#t_user_pwd').focus();
               return false;
            }
        if(n_user_pwd!=t_user_pwd)
            {
                $('#pop').html('<font color="red">新密码两次输入不一致，请确认后重新输入！</font>');
               $('#n_user_pwd').val('');
               $('#t_user_pwd').val('');
               $('#new_n_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#new_t_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#n_user_pwd').focus();
               return false;
            }
        if(n_user_pwd==user_pwd)
            {
                $('#pop').html('<font color="red">新旧密码一致，无需更改密码！</font>');
               $('#user_pwd').val('');
               $('#n_user_pwd').val('');
               $('#t_user_pwd').val('');
               $('#user_pwd').focus();
               return false;
            }
        return true;
    }
    
})
    


</script>
<include file="Public:logo" />
<include file="Public:menu" />
<include file="Public:table_br" />
<tbody><center>
<table width="780" border="1" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse" bordercolor="#000000">
<tr>
    <td width="15%" align="center" valign="top">
        <br>
        <include file="User:user_menu" />
    </td>
    <td width="85%" valign="top">
        <a href="{:U('User/index')}">个人中心</a>-修改密码
        <br><form name="login" method="POST">
        
        <a id="pop"></a>
        <br>
        原始密码：<input type="password" id="user_pwd" name="user_pwd" value="" maxlength="20" size="20" /><a id="new_pop"></a>(密码最长为20位)<br>
        新&nbsp;密&nbsp;码：<input type="password" id="n_user_pwd" name="n_user_pwd" maxlength="20" value="" size="20" /><a id="new_n_pop"></a>
        <br>
        确认密码：<input type="password" id="t_user_pwd" name="t_user_pwd" value="" maxlength="20" size="20" /><a id="new_t_pop"></a>
        <br>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="修改密码" id="tijiao" />
        </form>
    </td>
</tr>
</table>
</center></tbody>



<include file="Public:ender" />
